difficulties in javascript coding [on hold]
Posted
by
user3718986
on Stack Overflow
See other posts from Stack Overflow
or by user3718986
Published on 2014-06-12T21:13:20Z
Indexed on
2014/06/12
21:25 UTC
Read the original article
Hit count: 124
JavaScript
Question is,
It takes me 3 hours to fly from NY to CA. How much it will take me if I fly directly from NY to Florida. suppose that distance from CA to Flordia is 8 hours by air..Rule is if you suppose to travel from NY to Florida you will have to pass through CA.
I did the quesiton in JavaScript below but coding isn't correct. Can someone fixed this issue for me please?
var destination = prompt('Please enter your destinations. We are currently flying to NY,CA and FL');
var locatioon = prompt("specify your current location. ");
switch (destination) {
case 'NY':
{
distanceTeller(locatioon);
break;
}
break;
case 'CA':
{
distanceTeller(locatioon);
break;
}
break;
case 'FL':
{
alert("11 HR");
}
default:
alert('dont look at me');
break;
}
function distanceTeller(locatioon) {
if (locatioon == 'CA')
{
alert('it will take you 3 hours');
} else if (locatioon == 'FL')
{
alert('it will take you 8 hours');
} else
alert('it will take you 11 hours to reach NY');
}
© Stack Overflow or respective owner